import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class RiverpodPage extends ConsumerWidget {
  const RiverpodPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final counterProvider = StateProvider((ref) => 0);
    return Column(
      children: [
        Consumer(builder: (context, ref, _) {
          final count = ref.watch(counterProvider.state).state;
          return Text('$count');
        }),
        FloatingActionButton(
          onPressed: () {
            ref.read(counterProvider.state).state++;
          },
        )
      ],
    );
  }
}
